#ifndef GRID_H
#define GRID_H

#include <vector>
#include <cmath>
#include <exprtk.hpp>

class Grid {
public:
    Grid(const std::string& filename);
    std::vector<double> getGrid_1D() { 
        return grid_1D;
    }
    std::vector<std::vector<double>> getGrid_2D() { 
        return grid_2D;
    }
    std::function<double(double)> getExactSolution_1D() { 
        return exactSolution_1D;
    }
    std::function<double(double, double)> getExactSolution_2D() { 
        return exactSolution_2D;
    }
    std::function<double(double)> getSourceTerm_1D() { 
        return sourceTerm_1D;
    }
    std::function<double(double, double)> getSourceTerm_2D() { 
        return sourceTerm_2D;
    }

    int getN(){
        return n;
    }
    double geth(){
        return h;
    }
    int getDimension(){
        return dimension;
    }

private:
    int dimension; 
    int n;  // Number of grid points along each dimension
    double xmin, xmax, ymin, ymax;
    double h;  // Grid spacing

    std::vector<double> grid_1D; 
    std::vector<std::vector<double>> grid_2D;

    std::function<double(double)> exactSolution_1D;
    std::function<double(double, double)> exactSolution_2D;
    std::function<double(double)> sourceTerm_1D;
    std::function<double(double, double)> sourceTerm_2D;

    void loadFromJson(const std::string& filename);
    void generateGrid();
};

#endif